package com.example.myapplication

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.myapplication.databinding.FragmentABinding
import com.example.mylibrary.base.BaseFragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class FragmentA : BaseFragment() {
    private lateinit var mBinding: FragmentABinding

    @Inject
    lateinit var homeNavigator: HomeNavigator


    var value = "1"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("FragmentA", "--onCreate")
    }

    override fun createView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        if (this::mBinding.isInitialized.not()) {
            mBinding = FragmentABinding.inflate(inflater, container, false)
        }
        mBinding.action.setOnClickListener {
            value = "2"
            mBinding.action.text = "setOnClickListener"
            homeNavigator.navigatorToFragmentB()
        }
        Log.d("FragmentA", "--createView $value")
        return mBinding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        Log.d("FragmentA", "--onViewCreated")
    }

    override fun onResume() {
        super.onResume()
        Log.d("FragmentA", "--onResume")
    }
}
